#ifndef PROCESSWIDGET_H
#define PROCESSWIDGET_H

#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QTimer>

class ProcessWidget : public QWidget
{
    Q_OBJECT

public:
    enum ProcessStage {
        SmeltingStart = 0,    // 冶炼开始
        AddScrapSteel,        // 加废钢
        PourMoltenIron,       // 兑铁水
        BlowingStart,         // 吹炼开始
        BlowingEnd,           // 吹炼结束
        TappingSteel,         // 出钢
        SlagSplashing,        // 溅渣
        SlagRemoval,          // 出渣
        SmeltingEnd           // 冶炼结束
    };

    explicit ProcessWidget(QWidget *parent = nullptr);
    ~ProcessWidget();

    // 设置当前阶段
    void setCurrentStage(ProcessStage stage);
    ProcessStage getCurrentStage() const;
    
    // 设置时间
    void setCurrentTime(const QString &time);
    QString getCurrentTime() const;
    
    // 设置阶段完成状态
    void setStageCompleted(ProcessStage stage, bool completed);
    bool isStageCompleted(ProcessStage stage) const;

protected:
    void paintEvent(QPaintEvent *event) override;
    void resizeEvent(QResizeEvent *event) override;

private:
    void setupUI();
    void setupConnections();
    void updateLayout();
    QRect getStageRect(int stageIndex) const;
    void drawProgressLine(QPainter &painter);
    void drawStageMarkers(QPainter &painter);
    void drawStageLabels(QPainter &painter);
    
    // 布局组件
    QHBoxLayout *m_mainLayout;
    QLabel *m_timeLabel;
    QWidget *m_progressWidget;
    
    // 数据
    ProcessStage m_currentStage;
    QString m_currentTime;
    QVector<bool> m_stageCompleted;
    
    // 绘制参数
    int m_progressLineHeight;
    int m_stageMarkerRadius;
    int m_labelHeight;
};

#endif // PROCESSWIDGET_H
